package com.hualan.sfzy.service.impl;

import com.hualan.sfzy.mapper.CourseCollectMapper;
import com.hualan.sfzy.model.entity.CourseCollect;
import com.hualan.sfzy.service.CourseCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
@Service
public class CourseCollectServiceImpl implements CourseCollectService {
    @Autowired
    private CourseCollectMapper courseCollectMapper;

    @Override
    public int add(CourseCollect courseCollect) {
        int result = courseCollectMapper.selectExit(courseCollect);
        if (result>0) {
            return courseCollectMapper.update(courseCollect);
        }


        return courseCollectMapper.insert(courseCollect);
    }

    @Override
    public int remove(CourseCollect courseCollect) {
        return courseCollectMapper.delete1(courseCollect);
    }

    @Override
    public int selectByCourseId(int courseid) {
        return courseCollectMapper.selectCount(courseid);
    }

    @Override
    public int IsExist(CourseCollect courseCollect) {
        return courseCollectMapper.selectExit1(courseCollect);
    }
}
